const { Router } = require('express')
const {
  addCategory,
  pageCategory,
  getCategory,
  deleteCategory,
  updateCategory,
  getAllCategories,
} = require('../controllers/categoryController')
const interceptor = require('../middlewares/interceptor')
const restrictTo = require('../middlewares/restrictTo')

const router = Router()

router.post('/category', interceptor, restrictTo(['admin']), addCategory)
router.get('/category', pageCategory)
router.get('/category/all', getAllCategories)
router.get('/category/:id', getCategory)
router.delete('/category/:id', interceptor, restrictTo(['admin']), deleteCategory)
router.put('/category/:id', interceptor, restrictTo(['admin']), updateCategory)

module.exports = router
